#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @File   : b_object_program_higher.py.py
# @Email  : xuexia_xu@feidee.com
# @Time   : 2024/3/21 14:38
# @Desc   : @property

"""
面向对象高级编程：

Python内置的@property装饰器就是负责把一个方法变成属性调用的
"""


class Student(object):

    def __init__(self):
        self._score = None

    @property
    def score(self):
        return self._score

    @score.setter
    def score(self, value):
        if not isinstance(value, int):
            raise ValueError('score must be an integer!')
        if value < 0 or value > 100:
            raise ValueError('score must between 0 ~ 100!')
        self._score = value


if __name__ == '__main__':
    s = Student()
    s.score = 60
    print(s.score)
